package com.bwie.realtime.jtp.dwd.log.utils;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class AnalyzerUtils {
    public static List<String> ikAnalyzer(String content) throws Exception {
        ArrayList<String> list = new ArrayList<>();

//        分词对象
        IKSegmenter ikSegmenter  = new  IKSegmenter(
                new StringReader(content), true
        );

//        遍历
        Lexeme lexeme;

        while ((lexeme = ikSegmenter.next()) != null) {
            String text = lexeme.getLexemeText();
            list.add(text);
        }
//        返回
        return list;


    }

    public static void main(String[] args) throws Exception {
        List<String> list = ikAnalyzer("你好呀,你多大了");
        System.out.println(Arrays.toString(list.toArray()));
    }
}
